package com.gexiaobao.pigeon.ui.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.DataBindBaseViewHolder
import com.gexiaobao.pigeon.app.model.bean.OrderDrippingListResponse
import com.gexiaobao.pigeon.databinding.ItemDrippingOrderBinding

/**
 * @Author      : hxw
 * @Date        : 2024/6/22 13:54
 * @Describe    :
 */
class AdapterDrippingOrder(data: ArrayList<OrderDrippingListResponse.ListBean>) :
    BaseQuickAdapter<OrderDrippingListResponse.ListBean, DataBindBaseViewHolder>(
        R.layout.item_dripping_order, data
    ) {
    override fun convert(holder: DataBindBaseViewHolder, item: OrderDrippingListResponse.ListBean) {
        val binding = DataBindBaseViewHolder.getBinding(holder) as ItemDrippingOrderBinding
        binding.data = item
        binding.executePendingBindings()//防止列表抖动

        var orderStateContent = ""
        var orderStateBackground = 0
        var isChargeBack = false
        when (item.status) {//1创建2发布3已接单4已接鸽5已完成
            1 -> {
                isChargeBack = true
                orderStateContent = context.getString(R.string.have_published)
                orderStateBackground = R.drawable.round_bg25_003366_half
            }

            4 -> {
                isChargeBack = true
                orderStateContent = context.getString(R.string.Received_pigeon)
                orderStateBackground = R.drawable.round_bg25_003366_half
            }

            3 -> {
                isChargeBack = false
                orderStateContent = context.getString(R.string.Non_trading_order_has_been_received)
                orderStateBackground = R.drawable.round_bg25_003366_half
            }

            2 -> {
                isChargeBack = false
                orderStateContent = context.getString(R.string.Favorite_Single)
                orderStateBackground = R.drawable.round_bg8_red_half_top_bottom
            }

            else -> {
                isChargeBack = true
                orderStateContent = context.getString(R.string.market_shop_order_list_for_fragment_layout_activity_my_order_tab_complete)
                orderStateBackground = R.drawable.round_bg25_gray_half
            }
        }

        holder.setText(R.id.tvOrderState, orderStateContent)
        holder.setBackgroundResource(R.id.tvOrderState, orderStateBackground)
        holder.setGone(R.id.tvWithDrawAnOrder, isChargeBack)

        holder.setText(R.id.tvPigeonNumber, context.getString(R.string.Number_of_pigeon) + item.pigeons.size.toString() + context.getString(R.string.yu))
    }
}